<template>
	<view class="article">
		<view class="nav">
			<view :class="group== 'bid' ? 'avacity': ''" @click="navClick('bid')">我的题库</view>
			<view :class="group== 'cid' ? 'avacity': ''" @click="navClick('cid')">我的题型</view>
		</view>
		<view class="article-list" v-if="list.length > 0">
			<block v-if="group == 'bid'">
				<view class="article-list-view" v-for="(item,index) in list" @click="urlClick('/pages/bak/details?id='+item.bak.id)">
				
					<image :src="item.bak.img"></image>
					<view class="article-list-view-r">
						<view class="article-list-view-r-title">{{item.bak.name}}</view>				
						<view class="article-list-view-r-cennt">
							{{item.bak.brief}}
						</view>
						<view class="article-list-view-r-date">{{item.bak.issue_time}}</view>
					</view>
					
				</view>
			</block>
			<block v-if="group == 'cid'">
				<view class="article-list-view" v-for="(item,index) in list" @click="urlClick('/pages/cell/cell?cid='+item.classify.id)">
				
					<image :src="item.classify.banner"></image>
					<view class="article-list-view-r">
						<view class="article-list-view-r-title">{{item.classify.name}}</view>				
						<view class="article-list-view-r-cennt">
							{{item.classify.brief}}
						</view>
						<view class="article-list-view-r-date">{{item.classify.create_time}}</view>
					</view>
				</view>
			</block>
			
			
		</view>
		
		<view class="notavailable" v-else>
			<image src="../../static/zan.png"></image>
			<view>暂无数据</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page :1 ,
				limit : 10 ,
				list :[],
				count : 0,
				group : 'bid'
			}
		},
		onLoad() {
			this.getall();
		},
		onReachBottom(){
			this.page += 1;
			this.getall();
		},
		onPullDownRefresh() {
			this.page = 1;
			this.list= [];
			setTimeout(()=>{
				this.getall();
				uni.stopPullDownRefresh();
			},1000)
		},
		methods: {
			navClick(e){
				this.group  = e;
				this.list =  [];
				this.getall();
			},
			getall(){
				let that  = this;
				that.$like.getLike({'page':that.page,'limit':that.limit,'group':this.group}).then(res=>{
					that.list = [...that.list,...res.data.list];
					that.count= res.data.count;
				})
			},
			urlClick(e){
				uni.navigateTo({
					url:e
				})
			}
		}
	}
</script>

<style lang="less">
	@import url('../../common/css/article.less');
	.article-list-view-r-cennt {
		height: 70rpx !important;
	}
	.nav {
		display: flex;
		color: #333;
		padding-top: 16rpx;
		padding-bottom: 16rpx;
		border-bottom: 2rpx solid #e8e8e8;
		view {
			font-size: 34rpx;
			flex: 1;
			line-height: 80rpx;
			text-align: center;
		}
		.avacity {
			color: #3eb8ff;
		
			font-weight: bold;
		}
	}
</style>
